package net.suncaper.demo.service;

import net.suncaper.demo.domain.*;
import net.suncaper.demo.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service
public class QuestionServiceImpl implements QuestionService{
    @Autowired
    private GiveQuestionMapper giveQuestionMapper;
    @Autowired
    private SelectQuestionMapper selectquestionMapper;

    @Autowired
    private ReportMapper reportMapper;
    @Autowired
    private ReviewMapper reviewMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public List<GiveQuestion> findGiveQuestion() {
        return giveQuestionMapper.selectByExample(new GiveQuestionExample());
    }

    @Override
    public void saveGiveQuestion(GiveQuestion giveQuestion) {
        giveQuestionMapper.insert(giveQuestion);
    }

    @Override
    public void deleteGiveQuestionById(BigDecimal id) {
        giveQuestionMapper.deleteByPrimaryKey(id);
    }
    @Override
    public GiveQuestion findGiveQuestionById(BigDecimal id) {

        return giveQuestionMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SelectQuestion> findSelectQuestion() {
        return selectquestionMapper.selectByExample(new SelectQuestionExample());
    }

    @Override
    public SelectQuestion findSelectQuestionById(BigDecimal id) {
        return selectquestionMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateReport(Report report){
        reportMapper.updateByPrimaryKeyWithBLOBs(report);
    }
    @Override
    public void saveReport(Report report) {
        reportMapper.insert(report);
    }

    @Override
    public List<Report> findReport() {
        return reportMapper.selectByExampleWithBLOBs(new ReportExample());
    }

    @Override
    public Report findReportById(BigDecimal id) {
        return reportMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Review> FindReview(){

        return reviewMapper.selectByExampleWithBLOBs(new ReviewExample());
    }

    @Override
    public Review findReview(BigDecimal id) {
        return reviewMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveReview(Review review) {
        reviewMapper.insert(review);
    }
    @Override
   public Student findstudentById(String id){
        return studentMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveSelect(SelectQuestion selectQuestion) {
        selectquestionMapper.insert(selectQuestion);
    }
    @Override
    public GiveQuestion selectquestionByquestionId(BigDecimal questionId) {
        return giveQuestionMapper.selectByPrimaryKey(questionId);
    }
    @Override
    public Teacher findTeachername(String teacherId) {
        return teacherMapper.selectByPrimaryKey(teacherId);
    }
    @Override
    public void deleteQuestionById(BigDecimal questionId) {
        giveQuestionMapper.deleteByPrimaryKey(questionId);
    }

    @Override
    public GiveQuestion findQuestionById(BigDecimal questionId) {
        return giveQuestionMapper.selectByPrimaryKey(questionId);
    }
    @Override
    public void updateQuestion(GiveQuestion question) {
        giveQuestionMapper.updateByPrimaryKeyWithBLOBs(question);
    }
    @Override
    public List<Student> findStudent() {
        return studentMapper.selectByExample(new StudentExample());
    }
}
